﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hotnet.Biz.NSBizCommon;
using Hotnet.Entity.Enum;
using Hotnet.Entity;

namespace Hotnet.Biz.NSBizVideo
{
	class BizVideoAndVideoGroupCommon
	{
		private static BizTag bizTag = new BizTag();
		private static BizVideoXTag bizVideoXTag = new BizVideoXTag();
		private static BizCastCharacter bizCastCharacter = new BizCastCharacter();
		public void InsertVideoTags(string tags, int videoId)
		{
			List<int> tagIDs = bizTag.Save(tags, EnumTagType.视频).Distinct().ToList();
			List<VideoXTag> videoTags = new List<VideoXTag>();
			foreach (var id in tagIDs)
			{
				VideoXTag item = new VideoXTag();
				item.TagID = id;
				item.VideoID = videoId;
				videoTags.Add(item);
			}
			bizVideoXTag.Insert(videoTags);
		}

		public void InsertCastCharacters(string castCharacters, int videoId)
		{
			if (!string.IsNullOrEmpty(castCharacters))
			{
				string[] casts = castCharacters.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				List<CastCharacter> castCharacterList = new List<CastCharacter>();
				foreach (var castId in casts)
				{
					CastCharacter item = new CastCharacter();
					item.StarID = int.Parse(castId);
					item.VideoID = videoId;
					castCharacterList.Add(item);
				}
				bizCastCharacter.Insert(castCharacterList);
			}
		}
	}
}
